#include <QtTest>

#include "logparser.h"
class PresenceEntry
{
public:
    QDateTime m_startTime;
    QDateTime m_endTime;
};

class TestLogParser : public QObject, public LogParserHandler
{
    Q_OBJECT

private Q_SLOTS:
    void testParse();

protected:  //from LogParserHandler
    void newDay(const QDate& date);
    void newEntry(const QDateTime& startTime, const QDateTime& endTime);

private:
    QVector<PresenceEntry> m_entries;
};

void TestLogParser::testParse()
{
    LogParser parser(*this);
    parser.parse("test_log.log");
}

void TestLogParser::newDay(const QDate& date)
{
    qDebug() << "New day" << date;
    foreach (PresenceEntry e, m_entries)
    {
        qDebug() << e.m_startTime << e.m_endTime ;
    }
    m_entries.clear();
}

void TestLogParser::newEntry(const QDateTime& startTime, const QDateTime& endTime)
{
    //if (startTime.isNull() || endTime.isNull())
    //    qDebug() << startTime << endTime;
    PresenceEntry e;
    e.m_startTime = startTime;
    e.m_endTime = endTime;
    m_entries.append(e);
}

QTEST_MAIN(TestLogParser)
#include "testlogparser.moc"
